﻿@model IEnumerable<DotNetUniLodz.Models.Category>

@{
    ViewBag.Title = "Kategorie";
}

<div id="Content100">
    <h2>Kategorie</h2>

    @if (User.IsInRole("Admin"))
    {
        <header id="ContentHeaderLinks">
            @Html.ActionLink("+ Dodaj nową kategorię", "Create")
        </header>
    }

    <div id="Columns">
        <section id="News" class="News100">
            @foreach (var item in Model)
            {
                var newsCountForCategory = item.Articles.Count;
                <article class="Article100">
                    <header>
                        @Html.ActionLink(item.Category_name, "Details", "Categories", new { id = item.Category_name }, null) (@newsCountForCategory)
                    </header>

                    @if (User.IsInRole("Admin"))
                    {<footer>

                            <div class="AdminLinks">
                                @Html.ActionLink("Edytuj", "Edit", new { id = item.Category_id }) |
                        @Html.ActionLink("Usuń", "Delete", new { id = item.Category_id })
                            </div>
                        </footer>
                    }
                </article>
            }
        </section>
    </div>
</div>
